from abc import ABC, abstractmethod
from typing import Optional
from hello_agents.core import HelloAgentsLLM
from .config import Config
from .message import Message


class Agent(ABC):
    def __init__(
            self,
            name: str,
            llm: HelloAgentsLLM,
            system_prompt: Optional[str] = None,
            config: Optional[Config] = None
    ):
        self.name = name
        self.llm = llm
        self.system_prompt = system_prompt
        self.config = config or Config()
        self._history : list[Message] = []

        @abstractmethod
        def run(self, query: str, **kwargs) -> str:
            pass

        def add_message(self, message: Message):
            self._history.append(message)

        def get_history(self) -> list[Message]:
            return self._history

        def clear_history(self):
            self._history.clear()

        def __str__(self) -> str:
            return f"name: {self.name}, llm: ({self.llm}), provider: {self.llm.provider}"
